#include<iostream>
#include<cstdio>
using namespace std;
int n;
int a[200005];
int ne[200005];
int shang[200005];
int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	scanf("%d",&n);
	shang[n+1] = n;
	ne[0] = 1;
	for(int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		ne[i] = i+1;
		shang[i] = i-1;
	}
	int cnt = 0;
	while(cnt < n)
	{
		int now = -1;
		for(int i = ne[0];i <= shang[n+1];i = ne[i])
		{
			if(a[i] != now)
			{
				cnt++;
				printf("%d ",i);
				ne[shang[i]] = ne[i];
				shang[ne[i]] = shang[i];
				now = a[i];
			}
		}
		printf("\n");
	}
	return 0;
}
